<?php
	class Hethong extends CI_Controller
	{
		function admin_index()
		{
			$login = $this->session->userdata('islogin');
			if($login)
			{		
				
				$this->load->model('hethong_model');
				$data['dlkhoiphuc'] = NULL;
				$data['key'] = NULL;
				
				$data['chucvu'] = $this->session->userdata('chucvu');
				
				$data['current_username'] = $this->session->userdata('username');

				$this->load->view('admin/hethong_view', $data);
			}
			else
				redirect('login/admin_index');
		}
		function BackupDuLieu()
		{
			$login = $this->session->userdata('islogin');
			if($login)
			{
				$this->load->model('hethong_model');
				$result = $this->hethong_model->BackupDuLieu();
				$data['dlkhoiphuc'] = NULL;
					if($result)
					{
						echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
						?>
	        	        <script>
							alert("Thực hiện thành công!");
							window.location = "<?php echo base_url(); ?>index.php/hethong/admin_index";
						</script>
    	            	<?php
					}
					else
					{
						echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
						?>
    		            <script>
							alert("Thực hiện thất bại!");
							window.location = "<?php echo base_url(); ?>index.php/hethong/admin_index";
						</script>
	                	<?php
					}
			}
			else
				redirect('login/admin_index');
		}
		function XoaFile()
		{
			$login = $this->session->userdata('islogin');
			if($login)
			{			
				$tenfile = $this->uri->segment(3);
				if($tenfile)
				{
					$this->load->model('hethong_model');
					$result = $this->hethong_model->XoaFile($tenfile);
				
					if($result)
					{
						echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
						?>
	        	        <script>
							alert("Xóa file thành công!");
							window.location = "<?php echo base_url(); ?>index.php/hethong/admin_index";
						</script>
    	            	<?php
					}
					else
					{
						echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
						?>
    		            <script>
							alert("Xóa file thất bại!");
							window.location = "<?php echo base_url(); ?>index.php/hethong/admin_index";
						</script>
	                	<?php
					}
				}
			}
			else
				redirect('login/admin_index');
		}
		
		function download()
		{
			$login = $this->session->userdata('islogin');
			if($login)
			{			
				$tenfile = $this->uri->segment(3);
				if($tenfile)
				{
					$this->load->model('hethong_model');
					$result = $this->hethong_model->download($tenfile);
				
					if($result)
					{
						echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
						?>
	        	        <script>
							alert("Download file thành công!");
							window.location = "<?php echo base_url(); ?>index.php/hethong/admin_index";
						</script>
    	            	<?php
					}
					else
					{
						echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />";
						?>
    		            <script>
							alert("Download file thất bại!");
							window.location = "<?php echo base_url(); ?>index.php/hethong/admin_index";
						</script>
	                	<?php
					}
				}
			}
			else
				redirect('login/admin_index');
		}
		/*function KhoiPhucDuLieu()
		{
			$login = $this->session->userdata('islogin');
			if($login)
			{			
				$tenfile = $this->uri->segment(3);
				if($tenfile)
				{
					$this->load->model('hethong_model');
					$result = $this->hethong_model->KhoiPhucDuLieu($tenfile);
				
					if($result)
					{
						?>
	        	        <script>
							alert("Khôi phục thành công!");
							window.location = "<?php echo base_url(); ?>index.php/hethong/admin_index";
						</script>
    	            	<?php
					}
					else
					{
						?>
    		            <script>
							alert("Khôi phục thất bại!");
							window.location = "<?php echo base_url(); ?>index.php/hethong/admin_index";
						</script>
	                	<?php
					}
				}
			}
			else
				redirect('login/admin_index');
		}*/
		
	}
		
		
?>